import accountAPI from "@/api/waterMeter/accountAdmin";
import type { ISelectConfig } from "@/components/TableSelect/index.vue";

// 水表
const selectConfig: ISelectConfig = {
  pk: "id",
  width: "70%",
  placeholder: "请选择",
  formItems: [
    {
      type: "input",
      label: "户主姓名",
      prop: "s_holder_username",
      attrs: {
        placeholder: "户主姓名",
        clearable: true,
        style: {
          width: "200px",
        },
      },
    },
    {
      type: "input",
      label: "水表编号",
      prop: "s_code",
      attrs: {
        placeholder: "水表编号",
        clearable: true,
        style: {
          width: "200px",
        },
      },
    },
  ],
  indexAction: function (params) {
    if ("createAt" in params) {
      const createAt = params.createAt as string[];
      if (createAt?.length > 1) {
        params.startTime = createAt[0];
        params.endTime = createAt[1];
      }
      delete params.createAt;
    }
    return accountAPI.getPage(params);
  },
  tableColumns: [
    { type: "selection", width: 50, align: "center" },
    { label: "水表id", align: "center", prop: "id", width: 80 },
    { label: "水表编号", align: "center", prop: "code", width: 100 },
    { label: "户主姓名", align: "center", prop: "holder_username" },
    { label: "户主电话", align: "center", prop: "holder_tel", width: 120 },
  ],
};

export default selectConfig;
